<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class index extends CI_Controller {	
	 function __construct()
	 {
	  	parent::__construct();
	  	$this->load->helper('text');
	 }
	 function index()
	{
		$headTitle["title"]="中国乡土艺术协会_首页";
		$this->load->model('TB_News');
		//"xwzx","xhjg","whzx","hyzq","shmj","gyds","hzjl"
		$AllClassName=array("新闻资讯","协会机构","文化中心","会员专区","书画名家","工艺大师","合作交流");
		$newsTitle = array();
		$i=0;
		foreach($AllClassName as $ClassName)
		{
			$str='news'.$i;
			$newsTitle[$str]=$this->get_TenShowNews($ClassName);
			$i++;
		}		
		$this->load->view("header",$headTitle);
		$this->load->view("index",$newsTitle);
		$this->load->view("footer");
	}
	function get_TenShowNews($ClassName)
	{
		$data=	$this->TB_News->get_last_Ten_entries($ClassName);
		$newsTitle = array();
		$i=0;
		foreach($data as $OneRow)
		{
			$str='Title'.$i;
			$newsTitle[$str]=array($OneRow->TypeName,$OneRow->Title,character_limiter($OneRow->AddTime, 10,''));
		//	'['.$OneRow->TypeName.']'.$OneRow->Title;
				$str1='NewsID'.$i;
			$newsTitle[$str1]=$OneRow->NewsID;
			$i++;
		}
		if($i<10)
		{
			for($j=$i;$j<10;$j++)
			{
				$str='Title'.$j;
				$newsTitle[$str]=array(' ',' ',' ');
				//' ';
					$str1='NewsID'.$j;
				$newsTitle[$str1]=0;
			}
		}
			return $newsTitle;
	}

}